feat(trans): add translator work analysis command#20083
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4034c5b1e9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
### Motivation - Provide a lightweight management command to estimate realistic daily translator throughput by analyzing change history while avoiding noisy data (bots, bulk uploads, automated events and obvious outliers). - Make the analysis usable for projects/components/languages and bounded by date ranges for operational planning and reporting. ### Description - Add `weblate/trans/management/commands/analyze_translator_work.py` which groups unit-backed changes by user/day (actions: `CHANGE`, `NEW`, `ACCEPT`), filters to active non-bot users, and computes median/average/p75/p90 for translated strings and source words. - Add command options: `--days`, `--since`, `--until`, `--project`, `--component`, `--language`, `--min-changes`, `--max-changes`, and `--max-words` to scope and filter results. - Update documentation at `docs/admin/management.rst` to document the new command and add a changelog note in `docs/changes.rst` announcing the feature. ### Testing - `python -m compileall weblate/trans/management/commands/analyze_translator_work.py` completed successfully. - `.venv/bin/python manage.py analyze_translator_work --help` ran and displayed the expected help text. - `git diff --cached --check` passed with no problems reported for the changed files. - `uv run prek run ruff --files ...` could not be executed due to an environment network restriction when initializing hooks (external hook repo cloning failed), and `uv run mypy ...` produced existing project-wide type findings unrelated to the new command file.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c4235ddc8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
### Motivation
* Provide a way to estimate realistic daily translator throughput from change history while excluding bots, bulk imports, uploads and other outliers.
### Description
* Add new management command `analyze_translator_work` implemented in `weblate/trans/management/commands/analyze_translator_work.py` that aggregates change rows per user-day, filters by activity thresholds and outputs median/average/p75/p90 metrics for strings and source words per day.
* Command accepts arguments `--days`, `--since`, `--until`, `--project`, `--component`, `--language`, `--min-changes`, `--max-changes`, and `--max-words` and restricts the queryset to active human users and unit-backed changes.
* Document the new admin command in `docs/admin/management.rst` and add a release note entry in `docs/changes.rst`.
* Add unit test `AnalyzeTranslatorWorkTest` in `weblate/trans/tests/test_commands.py` (and adjust related imports) to validate grouping and reporting behavior for accepted suggestion changes.
### Testing
* Ran the Django unit tests including the new `AnalyzeTranslatorWorkTest` which invokes `call_command('analyze_translator_work', ...)`, and the test passed.
* Existing management command tests were exercised as part of the test run and completed successfully.
Motivation
Description
weblate/trans/management/commands/analyze_translator_work.pywhich groups unit-backed changes by user/day (actions:CHANGE,NEW,ACCEPT), filters to active non-bot users, and computes median/average/p75/p90 for translated strings and source words.--days,--since,--until,--project,--component,--language,--min-changes,--max-changes, and--max-wordsto scope and filter results.docs/admin/management.rstto document the new command and add a changelog note indocs/changes.rstannouncing the feature.Testing
python -m compileall weblate/trans/management/commands/analyze_translator_work.pycompleted successfully..venv/bin/python manage.py analyze_translator_work --helpran and displayed the expected help text.git diff --cached --checkpassed with no problems reported for the changed files.uv run prek run ruff --files ...could not be executed due to an environment network restriction when initializing hooks (external hook repo cloning failed), anduv run mypy ...produced existing project-wide type findings unrelated to the new command file.Codex Task